package entity;

import java.util.ArrayList;
import java.util.List;

abstract public class PokerPile {
	protected List<Poker> pokerList;	//牌成员
	public PokerPile() {
		pokerList=new ArrayList<>();
	}
	public List<Poker> getPokerList() {
		//System.out.println(pokerList);
		List<Poker> copyList=new ArrayList<>();
		if(pokerList!=null)
			for(int i=0;i<pokerList.size();i++)
				copyList.add(pokerList.get(i));
		return copyList;
	}
	public void setPokerList(List<Poker> pokerList) {
		this.pokerList = pokerList;
	}
	/**将手中的扑克放回该牌堆中
	 * 
	 * @param pokers	要放回的扑克
	 */
	public void putBack(List<Poker> pokers){
		List<Poker> tempList=new ArrayList<>();//新建一个List
		for(Poker poker:pokerList)	//首先添加原有的扑克
			tempList.add(poker);
		for(Poker poker:pokers)	//然后添加新的扑克
			tempList.add(poker);
		pokerList=tempList;
	}
	/**将一组牌放进牌组中
	 * 
	 * @param pokers
	 * @return
	 */
	public abstract boolean put(List<Poker> pokers);
	/**取走序号为no之后的牌
	 * 
	 * @param no 序号
	 * @return
	 */
	public abstract List<Poker> get(int no);
	/**打印牌组信息，方便调试
	 * 
	 * @return 牌组
	 */
	public String toString(){
		StringBuffer buffer=new StringBuffer();
		for(Poker poker:pokerList)
			buffer.append(poker.toString()).append(" ");
		return buffer.toString();
	}
	/**返回牌堆成员是否为空
	 * 
	 * @return
	 */
	public boolean isEmpty(){
		return pokerList==null||pokerList.isEmpty();
	}
	/**发牌时直接往排堆里放入一张新牌
	 * 
	 * @param poker 一张扑克
	 
	public abstract void addNewPoker(Poker poker);
	*/
}
